<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            text-align: center;
        }

        .nav {
            padding: 50px 20px;
        }

        .start {
            margin: 10px 30px;
        }

        .end {
            margin: 10px 30px;
        }

        h1 {
            color: red;
        }

        a {
            position: fixed;
            right: 50%;
            bottom: 5%;
            text-decoration: none;
            color: #000;
        }

        a:hover {
            color: red;
        }
    </style>
</head>

<body>
    <div class="box">
        <div class="head">
            <h3>
                随机点名
            </h3>
        </div>
        <div class="nav">
            有请:
            <h1 class="content">???</h1>
            回答问题
        </div>
        <button class="start">开始</button>
        <button class="end">结束</button>
    </div>
    <div>
        <a href="首页.html">返回首页</a>

    </div>
    <script>
        let timeid = 0
        let answer = 0
        const arr = ['小红', '小刚', '小美', '小强', '小兰', '小杨', '张三', '李四', '王五', '小周', '小吴', '小郑', '小王', '小徐', '小朱', '小沈', '小唐', '小姚']
        const cnt = document.querySelector('.content')
        const start = document.querySelector('.start')
        const end = document.querySelector('.end')
        start.addEventListener('click', function () {
            timeid = setInterval(function () {
                let random = parseInt(Math.random() * arr.length)
                cnt.innerText = arr[random]
            }, 35)
        })
        end.addEventListener('click', function () {
            clearInterval(timeid)
        })
        cnt.addEventListener('mouseenter', function () {
            clearInterval(timeid)
        })
        // cnt.addEventListener('mouseleave', function () {
        //     timeid = setInterval(function () {
        //         start.click()
        //     }, 35)
        // })
    </script>
</body>

</html>